<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/plugin/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body>
	<div class="ibox-content">
		<form class="form-horizontal" id="dataform"
			onsubmit="javascripr:return false;">
			<input type="hidden" name="tokenUrl" value="${tokenUrl}"> <input
				type="hidden" name="token" value="${token}">
			<c:if test="${obj ne null }">
				<input type="hidden" name="id" value="${obj.id }">
			</c:if>
			
			<div class="form-group">
				<label class="col-offset-1 col-sm-2 control-label">父级属性<span
					class="text-danger">*</span></label>
				<div class="col-sm-4">
					<select class="select2 form-control  "   size="1" name="parentId"
						id="parentId">
						<option value="0" selected="selected">一级属性</option>
					</select>
				</div>


				<label class="col-sm-2 control-label">属性名称 <span
					class="text-danger">*</span>
				</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" name="attrName"
						value="<c:out value="${obj.attrName }"></c:out>"
						nullmsg="属性名称不能为空">
				</div>
				
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">属性编码 </label>
				<div class="col-sm-4">
					<input type="text" class="form-control" name="attrCode"
						ignore="ignore" value="<c:out value="${obj.attrCode }"></c:out>"
						nullmsg="属性编码不能为空">
				</div>
				<label class="col-sm-2 control-label"> 排序 </label>
				<div class="col-sm-4">
					<input type="text" class="form-control" name="sequence"
						ignore="ignore" value="<c:out value="${obj.sequence }"></c:out>"
						nullmsg=" 排序不能为空">
				</div>
			</div>
			<div class="form-group">
			<label class="col-sm-2 control-label"> SKU属性 </label>
				<div class="col-sm-4">
					<select class="form-control" name="isSku" >
						<option value="1" <c:if test="${obj.isSku eq 1 }"> selected="selected"</c:if> >不是</option>
						<option value="2" <c:if test="${obj.isSku eq 2 }"> selected="selected"</c:if>  >是</option>
					</select>
				</div>
				
				<div class="form-group">
				<label class="col-sm-2 control-label">展示图片</label>
				<div class="col-sm-4">
					<input value="${obj.img }" name="img" id="adImg"
						class="form-control  upload-input" type="text" /> <a
						class="btn btn-primary radius upload-a">选择图片
					</a>
				</div>
			</div>
			 
			</div>
			<div class="form-group ">
				<div class="col-sm-12 text-center">
					<a href="javascript:;" onclick="myForm.submit()"
						class="btn btn-success radius"><i class="fa fa-check"></i> 保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a class="btn btn-danger radius" href="javascript:;"
						onclick="MTools.closeForm()"><i class="fa fa-close"></i> 关闭</a>
				</div>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript"
	src="${path }/resource/js/systools/MJsBase.js"></script>
<script type="text/javascript">
 
	
	var invokeUrl = "${path}/do/admin/productAttrDef/addProductAttrDef";
	<c:if test="${obj ne null }">
	invokeUrl = "${path}/do/admin/productAttrDef/modifyProductAttrDef";
	</c:if>
	var myForm = MForm.initForm({
		invokeUrl : invokeUrl,
		afterSubmit : function() {
			parent.myGrid.serchData();
		},
	});
	
	initFunctionList();
	$(".select2").select2();
	MUI.initImgUpload(".upload-input");
	/**
	 * 初始化文章类型列表
	 */
	function initFunctionList() {
		$.AjaxProxy({a : false,c : false}).invoke("${path}/do/admin/productAttrDef/all", function(loj) {
			$("#parentId").createSelectTree(
					loj.attr("result").rows,
					{	id : "id",		// 选项的值
						parent : "parentId",	// 父节点值
						value : "attrName",	// 要显示的名称
						append : false, 
						defaultValue : "${obj.parentId}",
						defaultHtml : '<option value="0" selected="selected">一级属性</option>'
					});
			
		});

	}
</script>
</body>
</html>